/* SPDX-License-Identifier: GPL-2.0 */
#ifndef SEMINIX_TYPES_H
#define SEMINIX_TYPES_H

#ifndef __ASSEMBLY__

#include <asm/bitsperlong.h>

#if __BITS_PER_LONG != 64
typedef unsigned int usize;
typedef __signed__ int isize;
typedef int        ptrdiff_t;
#else
typedef unsigned long usize;
typedef __signed__ long isize;
typedef long       ptrdiff_t;
#endif

typedef unsigned char __u8;
typedef __signed__ char __i8;

typedef unsigned short __u16;
typedef __signed__ short __i16;

typedef unsigned int __u32;
typedef __signed__ int __i32;

#ifdef __GNUC__
__extension__ typedef unsigned long long __u64;
__extension__ typedef __signed__ long long __i64;
#else
typedef unsigned long long __u64;
typedef __signed__ long long __i64;
#endif

typedef __u8 u8;
typedef __i8 i8;

typedef __u16 u16;
typedef __i16 i16;

typedef __u32 u32;
typedef __i32 i32;

typedef __u64 u64;
typedef __i64 i64;

#define __bitwise

typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __le32;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __le64;
typedef __u64 __bitwise __be64;

typedef usize phys_addr_t;
typedef usize dma_addr_t;

typedef phys_addr_t resource_size_t;

typedef _Bool			bool;

typedef unsigned long		uintptr_t;

typedef unsigned int __bitwise gfp_t;

typedef long suseconds_t;
typedef int clockid_t;

typedef long clock_t;

typedef int pid_t;
typedef unsigned int uid32_t;

typedef int timer_t;

typedef long off_t;
typedef long long loff_t;

#define S8_C(x)  x
#define U8_C(x)  x ## U
#define S16_C(x) x
#define U16_C(x) x ## U
#define S32_C(x) x
#define U32_C(x) x ## U
#define S64_C(x) x ## LL
#define U64_C(x) x ## ULL

typedef struct {
    i32 counter;
} atomic_t;

#define ATOMIC_INIT(i) { (i) }

#ifdef CONFIG_64BIT
typedef struct {
    long long counter;
} atomic64_t;
#endif

#else

#define S8_C(x)  x
#define U8_C(x)  x
#define S16_C(x) x
#define U16_C(x) x
#define S32_C(x) x
#define U32_C(x) x
#define S64_C(x) x
#define U64_C(x) x

#endif /* !__ASSEMBLY__ */

#include <seminix/compiler.h>
#include <seminix/stddef.h>

#endif /* !SEMINIX_TYPES_H */
